import { createApp } from 'vue'
import App from './App.vue'
// reset style sheet
import '@/styles/reset.scss'
// CSS common style sheet
import '@/styles/common.scss'
// iconfont css
import '@/assets/iconfont/iconfont.scss'
// font css
import '@/assets/fonts/font.scss'
// element css
import 'element-plus/dist/index.css'
// element dark css
import 'element-plus/theme-chalk/dark/css-vars.css'
// custom element dark css
import '@/styles/element-dark.scss'
// custom element css
import '@/styles/element.scss'
// svg icons
import 'virtual:svg-icons-register'
// element plus
import ElementPlus from 'element-plus'
// element icons
import * as Icons from '@element-plus/icons-vue'
// vue i18n
import I18n from '@/languages/index'
// custom directives
import directives from '@/directives/index'
// vue Router
import router from '@/routers'
// pinia store
import pinia from '@/stores'
// errorHandler
import errorHandler from '@/utils/errorHandler'
import { init } from '@/utils/param'
const app = createApp(App)

app.config.errorHandler = errorHandler

// 全局挂载和注册 element-plus 的所有 icon
app.config.globalProperties.$icons = []

// register the element Icons component
for (const [key, component] of Object.entries(Icons)) {
  app.config.globalProperties.$icons.push(key)
  app.component(key, component)
}
app.use(ElementPlus).use(directives).use(router).use(I18n).use(pinia)
init().finally(() => {
  app.mount('#app')
})
